import wx
import sys
import os
from eRecruiterObjects import AreaWeightObject

class ImportanceFrame(wx.Dialog):
    def __init__(self,areas, title = "Select the Value of scoring areas"):
        wx.Dialog.__init__(self, None, -1, title,pos=(150,150),size=(400,400))
        
        self.areas = areas
        panel = wx.Panel(self, -1, size=(400,400))
        if ('Leadership' in areas) or ('Skills' in areas) or ('Certifications' in areas) or ('Teamwork' in areas) :
            wx.StaticText(panel,-1,'Area',(20,20))
            wx.StaticText(panel,-1,'Threshold',(160,5))
            wx.StaticText(panel,-1,'High',(215,20))
            wx.StaticText(panel,-1,'Low',(130,20))
            wx.StaticText(panel,-1,'Importance',(290,5))
            wx.StaticText(panel,-1,'High',(335,20))
            wx.StaticText(panel,-1,'Low',(280,20))
            wx.StaticLine(panel, -1, (15, 35), (370,1))
        

        vert_pos = 40;
        if 'Leadership' in areas:
            wx.StaticText(panel,-1,'Leadership',(20,vert_pos))
            self.LeadershipSLD = wx.Slider(panel, -1, 50, 0, 80, (120,vert_pos), (130, -1) )
            self.LeadershipSLD.SetToolTip(wx.ToolTip('Set the threshold for the amount of leadership a resume needs for their leadership to count'))
            self.Leadership_rb1 = wx.RadioButton(panel, -1, '', (280, vert_pos), style=wx.RB_GROUP)
            self.Leadership_rb2 = wx.RadioButton(panel, -1, '', (295, vert_pos))
            self.Leadership_rb3 = wx.RadioButton(panel, -1, '', (310, vert_pos))
            self.Leadership_rb4 = wx.RadioButton(panel, -1, '', (325, vert_pos))
            self.Leadership_rb5 = wx.RadioButton(panel, -1, '', (340, vert_pos))
            vert_pos += 25
            
        if 'Skills' in areas:
            wx.StaticText(panel,-1,'Skills',(20,vert_pos))
            self.SkillsSLD = wx.Slider(panel, -1, 50, 0, 80, (120,vert_pos), (130, -1) )
            self.SkillsSLD.SetToolTip(wx.ToolTip('Set the threshold for the amount of desired skills a resume needs for their skills to count'))
            self.Skills_rb1 = wx.RadioButton(panel, -1, '', (280, vert_pos), style=wx.RB_GROUP)
            self.Skills_rb2 = wx.RadioButton(panel, -1, '', (295, vert_pos))
            self.Skills_rb3 = wx.RadioButton(panel, -1, '', (310, vert_pos))
            self.Skills_rb4 = wx.RadioButton(panel, -1, '', (325, vert_pos))
            self.Skills_rb5 = wx.RadioButton(panel, -1, '', (340, vert_pos))
            vert_pos += 25

        

        if 'Certifications' in areas:
            wx.StaticText(panel,-1,'Certifications',(20,vert_pos))
            self.CertsSLD = wx.Slider(panel, -1, 50, 0, 80, (120,vert_pos), (130, -1) )
            self.CertsSLD.SetToolTip(wx.ToolTip('Set the threshold for the amount of desired certifications a resume needs for their certifications to count'))
            self.Certs_rb1 = wx.RadioButton(panel, -1, '', (280, vert_pos), style=wx.RB_GROUP)
            self.Certs_rb2 = wx.RadioButton(panel, -1, '', (295, vert_pos))
            self.Certs_rb3 = wx.RadioButton(panel, -1, '', (310, vert_pos))
            self.Certs_rb4 = wx.RadioButton(panel, -1, '', (325, vert_pos))
            self.Certs_rb5 = wx.RadioButton(panel, -1, '', (340, vert_pos))
            vert_pos += 25

        if 'Loyal' in areas:
            wx.StaticText(panel,-1,'Loyalty',(20,vert_pos))
            self.LoyalSLD = wx.Slider(panel, -1, 50, -5, 5, (120,vert_pos), (130, -1) )
            self.LoyalSLD.SetToolTip(wx.ToolTip('Set the threshold for the relative time spent per company.  We will filter for values above this threshold'))
            self.Loyal_rb1 = wx.RadioButton(panel, -1, '', (280, vert_pos), style=wx.RB_GROUP)
            self.Loyal_rb2 = wx.RadioButton(panel, -1, '', (295, vert_pos))
            self.Loyal_rb3 = wx.RadioButton(panel, -1, '', (310, vert_pos))
            self.Loyal_rb4 = wx.RadioButton(panel, -1, '', (325, vert_pos))
            self.Loyal_rb5 = wx.RadioButton(panel, -1, '', (340, vert_pos))
            vert_pos += 25

        if 'Adapt' in areas:
            wx.StaticText(panel,-1,'Adaptability',(20,vert_pos))
            self.AdaptSLD = wx.Slider(panel, -1, 50, 0, 100, (120,vert_pos), (130, -1) )
            self.AdaptSLD.SetToolTip(wx.ToolTip('Set the threshold for the relative time spent per company. We will filter for values below this threshold'))
            self.Adapt_rb1 = wx.RadioButton(panel, -1, '', (280, vert_pos), style=wx.RB_GROUP)
            self.Adapt_rb2 = wx.RadioButton(panel, -1, '', (295, vert_pos))
            self.Adapt_rb3 = wx.RadioButton(panel, -1, '', (310, vert_pos))
            self.Adapt_rb4 = wx.RadioButton(panel, -1, '', (325, vert_pos))
            self.Adapt_rb5 = wx.RadioButton(panel, -1, '', (340, vert_pos))
            vert_pos += 25
            
        if 'Teamwork' in areas:
            wx.StaticText(panel,-1,'Teamwork',(20,vert_pos))
            self.Teamwork_rb1 = wx.RadioButton(panel, -1, '', (280, vert_pos), style=wx.RB_GROUP)
            self.Teamwork_rb2 = wx.RadioButton(panel, -1, '', (295, vert_pos))
            self.Teamwork_rb3 = wx.RadioButton(panel, -1, '', (310, vert_pos))
            self.Teamwork_rb4 = wx.RadioButton(panel, -1, '', (325, vert_pos))
            self.Teamwork_rb5 = wx.RadioButton(panel, -1, '', (340, vert_pos))
            vert_pos += 25

        wx.StaticLine(panel, -1, (15, vert_pos ), (370,1))
        vert_pos += 10
        if 'Education' in areas:
            vert_pos += 10
            wx.StaticText(panel,-1,'Education',(20,vert_pos))
            wx.StaticText(panel,-1,'Required Majors',(120,vert_pos))
            self.EduMajorsReqTEXTBOX = wx.TextCtrl(panel, -1,pos=(120,vert_pos + 15),size=(130,40),style=wx.TE_MULTILINE)
            wx.StaticText(panel,-1,'Desired Majors',(120,vert_pos + 55))
            self.EduMajorsDesTEXTBOX = wx.TextCtrl(panel, -1,pos=(120,vert_pos + 70),size=(130,40),style=wx.TE_MULTILINE)
            self.Edu_rb1 = wx.RadioButton(panel, -1, '', (280, vert_pos), style=wx.RB_GROUP)
            self.Edu_rb2 = wx.RadioButton(panel, -1, '', (295, vert_pos))
            self.Edu_rb3 = wx.RadioButton(panel, -1, '', (310, vert_pos))
            self.Edu_rb4 = wx.RadioButton(panel, -1, '', (325, vert_pos))
            self.Edu_rb5 = wx.RadioButton(panel, -1, '', (340, vert_pos))
            vert_pos += 100

        

        if 'AreasOfExpertise' in areas:
            vert_pos += 10
            wx.StaticText(panel,-1,'Areas Of Expetise',(20,vert_pos))
            wx.StaticText(panel,-1,'Required Areas',(120,vert_pos))
            self.AreasOfExperReqTEXTBOX = wx.TextCtrl(panel, -1,pos=(120,vert_pos +15),size=(130,40),style=wx.TE_MULTILINE)
            wx.StaticText(panel,-1,'Desired Areas',(120,vert_pos + 55))
            self.AreasOfExperDesTEXTBOX = wx.TextCtrl(panel, -1,pos=(120,vert_pos + 70),size=(130,40),style=wx.TE_MULTILINE)
            self.AreasOfExp_rb1 = wx.RadioButton(panel, -1, '', (280, vert_pos), style=wx.RB_GROUP)
            self.AreasOfExp_rb2 = wx.RadioButton(panel, -1, '', (295, vert_pos))
            self.AreasOfExp_rb3 = wx.RadioButton(panel, -1, '', (310, vert_pos))
            self.AreasOfExp_rb4 = wx.RadioButton(panel, -1, '', (325, vert_pos))
            self.AreasOfExp_rb5 = wx.RadioButton(panel, -1, '', (340, vert_pos))
            vert_pos += 65
        
        
        self.findBTN = wx.Button(panel, -1, "Ok", (300,340))



    def Close(self):
            self.Destroy()

    def GetAreaDictionary(self):
        area_weight = AreaWeightObject()
        if 'Leadership' in self.areas:
            ranking = 0
            if self.Leadership_rb1.GetValue():
                ranking = 1
            elif self.Leadership_rb2.GetValue():
                ranking = 2
            elif self.Leadership_rb3.GetValue():
                ranking = 3
            elif self.Leadership_rb4.GetValue():
                ranking = 4
            elif self.Leadership_rb5.GetValue():
                ranking = 5
            area_weight.Leadership = [ self.LeadershipSLD.GetValue(), ranking]
        if 'Skills' in self.areas:
            ranking = 0
            if self.Skills_rb1.GetValue():
                ranking = 1
            elif self.Skills_rb2.GetValue():
                ranking = 2
            elif self.Skills_rb3.GetValue():
                ranking = 3
            elif self.Skills_rb4.GetValue():
                ranking = 4
            elif self.Skills_rb5.GetValue():
                ranking = 5
            area_weight.Skills = [ self.SkillsSLD.GetValue(), ranking]
        if 'Certifications' in self.areas:
            ranking = 0
            if self.Certs_rb1.GetValue():
                ranking = 1
            elif self.Certs_rb2.GetValue():
                ranking = 2
            elif self.Certs_rb3.GetValue():
                ranking = 3
            elif self.Certs_rb4.GetValue():
                ranking = 4
            elif self.Certs_rb5.GetValue():
                ranking = 5
            area_weight.Certs = [ self.CertsSLD.GetValue(), ranking]
        if 'Education' in self.areas:
            ranking = 0
            if self.Edu_rb1.GetValue():
                ranking = 1
            elif self.Edu_rb2.GetValue():
                ranking = 2
            elif self.Edu_rb3.GetValue():
                ranking = 3
            elif self.Edu_rb4.GetValue():
                ranking = 4
            elif self.Edu_rb5.GetValue():
                ranking = 5
            reqeduMajors = self.EduMajorsReqTEXTBOX.GetValue().replace('\n',',').lower().split(',')
            reqeduMajors = [s.lstrip().rstrip() for s in reqeduMajors]
            if '' in reqeduMajors:
                reqeduMajors.remove('')
            deseduMajors = self.EduMajorsDesTEXTBOX.GetValue().replace('\n',',').lower().split(',')
            deseduMajors = [s.lstrip().rstrip() for s in deseduMajors]
            if '' in deseduMajors:
                deseduMajors.remove('')
            area_weight.Education = [ reqeduMajors , ranking , deseduMajors ]
        if 'Loyalty' in self.areas:
            ranking = 0
            if self.Loyal_rb1.GetValue():
                ranking = 1
            elif self.Loyal_rb2.GetValue():
                ranking = 2
            elif self.Loyal_rb3.GetValue():
                ranking = 3
            elif self.Loyal_rb4.GetValue():
                ranking = 4
            elif self.Loyal_rb5.GetValue():
                ranking = 5
            area_weight.Loyalty = [ self.LoyalSLD.GetValue(), ranking, 1]
        if 'Adapt' in self.areas:
            ranking = 0
            if self.Adapt_rb1.GetValue():
                ranking = 1
            elif self.Adapt_rb2.GetValue():
                ranking = 2
            elif self.Adapt_rb3.GetValue():
                ranking = 3
            elif self.Adapt_rb4.GetValue():
                ranking = 4
            elif self.Adapt_rb5.GetValue():
                ranking = 5
            area_weight.Loyalty = [ self.AdaptSLD.GetValue(), ranking, 0]    
        if 'AreasOfExpertise' in self.areas:
            ranking = 0
            if self.AreasOfExp_rb1.GetValue():
                ranking = 1
            elif self.AreasOfExp_rb2.GetValue():
                ranking = 2
            elif self.AreasOfExp_rb3.GetValue():
                ranking = 3
            elif self.AreasOfExp_rb4.GetValue():
                ranking = 4
            elif self.AreasOfExp_rb5.GetValue():
                ranking = 5
            req_areaKeywords = self.AreasOfExperReqTEXTBOX.GetValue().replace('\n',',').lower().split(',')
            req_areaKeywords = [s.lstrip().rstrip() for s in req_areaKeywords]
            if '' in req_areaKeywords:
                req_areaKeywords.remove('')
            des_areaKeywords = self.AreasOfExperDesTEXTBOX.GetValue().replace('\n',',').lower().split(',')
            des_areaKeywords = [s.lstrip().rstrip() for s in des_areaKeywords]
            if '' in des_areaKeywords:
                des_areaKeywords.remove('')
            area_weight.AreasOfExpertise = [ req_areaKeywords , des_areaKeywords ,ranking]
            

            
        return area_weight
